<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<div class="go-top"></div>
<script>
    $(function () {
        var goTop = $(".go-top");
//        var top = document.body.scrollTop;
        var dom = document.documentElement;
        var t;
        dom.addEventListener('touchmove', function (event) {
            var top = document.body.scrollTop;
            if (top > 100) {
                //touchmove
                goTop.addClass("go-rig");
                clearTimeout(t);
            }else{
                goTop.removeClass('go-rig');
            }

        }, false);
        //touchend事件
        dom.addEventListener('touchend', function () {
            t = setTimeout("$('.go-top').removeClass('go-rig')", 3000);
        }, false);

    })

    $(".go-top").click(function () {
        var speed = 200;//滑动的速度
        $('body,html').animate({scrollTop: 0}, speed);
        return false;
    });

</script>
